<template>
	<view class="container">
		<view class="content">
			<view class="photo">
				<image src="https://xw-exam2.oss-cn-hangzhou.aliyuncs.com/exam/photo/2020/1592837674562.jpg" mode="aspectFill"></image>
			</view>
			
			<!-- 内容通栏 -->
			<uni-card is-full="true" :title="list.startTime | dateModule" thumbnail="../../static/shouye_03.png">
				<view class="list">
					<view style="font-weight: bold;">
						<p>{{list.title}}</p> 
					</view>
					<p>{{list.leave}}级</p>
				</view>
			</uni-card>
			
			<view style="margin: 80rpx;">
				<button plain="true" type="primary" @click="starAnswer">开始答题</button>
			</view>
		</view>
	</view>
</template>
<script>
	import {start,exam} from '../../apis'
    export default {
        data() {
            return {
				examId:0,
				list:{
					title:'',
					startTime:0,
					leave:0,
					state:0
				}
            }
        },
		onLoad(option) {
			console.log(typeof(parseInt(option.startTime)))
			this.list.startTime = parseInt(option.startTime)
			this.examId = option.id
			this.list.title = option.title
			this.list.leave = option.leave
			this.list.state = option.state
			console.log("this.list.state为："+this.list.state)
		},
        methods: {
           starAnswer() {
			   // console.log(this.examId)
			   if((new Date()).valueOf()<this.list.startTime){
				   uni.showToast({
				   	title:'报名成功，请同学们注意考试时间，准时前来答题，逾期将不能参加本次考试！',
					icon:'none',
					duration:3000
				   })
			    }else if(this.list.state == 3){
					   uni.showToast({
						title:'该场考试已结束，请同学们注意考试时间，准时前来答题，逾期将不能参加本次考试！',
						icon:'none',
						duration:3000
					   }) 
				    }else{
					    uni.navigateTo({
							url: '../answerCar/answerCar?examId='+this.examId+'&leave='+this.list.leave
					    });
				    }
		   }
		   // ,
		   // end() {
			  //  uni.navigateTo({
					// url: '../handInExam/handInExam'
			  //  });
		   // }
        }
    }
</script>

<style lang="scss" scoped>
	.content{
			width: 95%;
		.photo{
			height: 150px;
			border: 1px solid #C0C0C0;
			margin: 0 auto;
			margin-top: 10px;
			margin-bottom: 15px;
		}
		.list{
			text-align: center;
			padding-top: 10px;
			padding-bottom: 10px;
		}
		.info{
			width: 20%;
			margin: 10px auto;
			border: 2px solid #C0C0C0;
			text-align: center;
			padding: 5px;
			
		}
	}
</style>


